package it.pir.es04ChatMulticast;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.UnknownHostException;

public class ClientTest {
	
	private static final int PORT = 7777;
	private static final String HOST = "239.255.255.255";
	public static void main(String[] args) throws UnknownHostException, IOException, ClassNotFoundException {
		String nickname = args[0];
		BufferedReader tastiera = new BufferedReader(new InputStreamReader(System.in));
		Client client = new Client(nickname, HOST, PORT);
		
		/* Eseguimao il thread che legge in continuazione se arrivano messaggi*/
		Thread t = new Thread(client);
		t.start();
		
		/* Contemporaneamente nel thread principale (il main) inviamo messaggi*/
		while(true) {
			String s = tastiera.readLine();
			client.sendMessage(new Message(nickname, s, Message.MESSAGE));
		}
	}

}
